enum PrintLevel {
    INFO,
    ERROR
}

export class Logger {
    public static debug = false

    public static info(tag: string, ...contents: Object[]) {
        if (!Logger.debug) {
            return
        }
        Logger.log(PrintLevel.INFO, tag, ...contents)
    }

    public static error(tag: string, ...contents: Object[]) {
        if (!Logger.debug) {
            return
        }
        Logger.log(PrintLevel.ERROR, tag, ...contents)
    }

    private static log(level: PrintLevel, tag: string, ...contents: Object[]) {
        for (const content of contents) {
            const dataType = typeof content
            if (content == undefined
                || dataType == null
                || dataType == 'string'
                || dataType == 'boolean'
                || dataType == 'number'
                || dataType == 'bigint') {
                Logger.print(level, tag, content)
            } else {
                Logger.print(level, tag, JSON.stringify(content))
            }
        }
    }

    private static print(level: PrintLevel, tag: string, content: any) {
        if (level === PrintLevel.INFO) {
            if(tag===undefined||tag===null||tag==''){
                console.info(content)
            }else{
                console.info(tag, content)
            }
            return
        }
        if (level === PrintLevel.ERROR) {
            if(tag===undefined||tag===null||tag==''){
                console.error(content)
            }else{
                console.error(tag, content)
            }
            return;
        }
    }
}